Shortages

Column

Total number of drugs in shortage over time

Shortage start date

Column

Duration of shortages

Causes of drug shortages

Column

Active shortages

1621

Anticipated shortages next week

1585

Summary (via the database)

status n
resolved 6741
active_confirmed 2001
avoided_shortage 248
anticipated_shortage 51

Essential Medicines

Column

Essential medicines impacted by shortages in 2019

Category Medication ATC Shortages
Cardiovascular - Antihypertensives Candesartan C09CA06 67
Cardiovascular - Antihypertensives Diltiazem C08DB01 58
Alimentary - Acid Ranitidine A02BA02 48
Cardiovascular - Cholesterol Pravastatin C10AA03 35
Alimentary - Acid Pantoprazole A02BC02 33
Genito-urinary - ED Tadalafil G04BE08 33
Cardiovascular - Antihypertensives Ramipril C09AA05 31
Genito-urinary - Androgens Testosterone G03BA03 25
Neurological - Gabapentin Gabapentin N03AX12 24
Cardiovascular - Antihypertensives Amlodipine C08CA01 22
Alimentary - Non-insulin Metformin A10BA02 21
Cardiovascular - Cholesterol Atorvastatin C10AA05 20
Dermatological Betamethasone D07AC01 20
Neurological - Antidepressants Sertraline N06AB06 20
Antiinfectives - Antibiotics Ciprofloxacin J01MA02 19
Neurological - Antipsychotics Risperidone N05AX08 19
Neurological - Other Carbamazepine N03AF01 18
Neurological - Other Levodopa/carbidopa N04BA02 18
Neurological - Dementia Donepezil N06DA02 16
Cardiovascular - Other Epinephrine C01CA24 14
Dermatological Hydrocortisone D07AA02 14
Neurological - ADHD Atomoxetine N06BA09 14
Neurological - Antidepressants Fluoxetine N06AB03 14
Neurological - Opioids Morphine N02AA01 14
Neurological - Other Valproic acid N03AG01 14
Neurological - Benzodiazepines Diazepam N05BA01 13
Antiinfectives - Antibiotics Azithromycin J01FA10 12
Antiinfectives - Antibiotics Levofloxacin J01MA12 11
Antiinfectives - Other Valacyclovir J05AB11 11
Blood - Antiplatelets Clopidogrel B01AC04 11
Genito-urinary - Contraception Ethinylestradiol/ levonorgestrel G03AA07 10
Respiratory - Airway Salbutamol R03AC02 10
Musculo-skeletal - Osteoporosis Alendronate M05BA04 9
Antiinfectives - Antibiotics Clindamycin J01FF01 8
Hormonal - Other Methylprednisolone H02AB04 8
Musculo-skeletal - NSAIDs Naproxen M01AE02 8
Sensory - Other Olopatadine S01GX09 8
Cardiovascular - Antihypertensives Labetalol C07AG01 7
Genito-urinary - BPH Finasteride G04CB01 7
Musculo-skeletal - NSAIDs Ibuprofen M01AE01 7
Neurological - Migraine Eletriptan N02CC06 7
Antiinfectives - Antibiotics Clarithromycin J01FA09 6
Antiinfectives - Antibiotics Metronidazole J01XD01 6
Antiinfectives - Other Fluconazole J02AC01 6
Cardiovascular - Other Furosemide C03CA01 6
Genito-urinary - HRT Estradiol (17β-estradiol) G03CA03 6
Hormonal - Other Dexamethasone H02AB02 6
Neurological - Opioids Hydromorphone N02AA03 6
Neurological - Other Acetaminophen N02BE01 6
Respiratory - Airway Ipratropium R03BB01 6
Alimentary - Other Domperidone A03FA03 5
Antiinfectives - Antibiotics Amoxicillin J01CA04 5
Antiinfectives - Antibiotics Cephalexin J01DB01 5
Blood - Anticoagulants Dabigatran etexilate B01AE07 5
Dermatological Mupirocin D06AX09 5
Dermatological Nystatin D01AA01 5
Musculo-skeletal - Other Baclofen M03BX01 5
Neurological - Antipsychotics Haloperidol N05AD01 5
Neurological - Other Acetylsalicylic acid N02BA01 5
Alimentary - Non-insulin Gliclazide A10BB09 4
Alimentary - Other Sulfasalazine A07EC01 4
Antiinfectives - Antibiotics Amoxicillin/ clavulanic acid J01CR02 4
Blood - Anticoagulants Warfarin B01AA03 4
Blood - Other Tranexamic acid B02AA02 4
Blood - Other Vitamin B12 B03BA01 4
Dermatological Clotrimazole D01AC01 4
Dermatological Tretinoin D10AD01 4
Genito-urinary - BPH Tamsulosin G04CA02 4
Neurological - Other Phenytoin N03AB02 4
Sensory - Glaucoma Latanoprost S01EE01 4
Alimentary - Antidiarrhoeal Loperamide A07DA03 3
Alimentary - Other Metoclopramide A03FA01 3
Alimentary - Other Potassium A12BA01 3
Antiinfectives - Antibiotics Cloxacillin J01CF02 3
Cardiovascular - Other Nitroglycerin C01DA02 3
Hormonal - Thyroid Levothyroxine H03AA01 3
Neurological - Other Varenicline N07BA03 3
Sensory - Glaucoma Pilocarpine S01EB01 3
Alimentary - Other Thiamine A11DA01 2
Blood - Other Folic acid B03BB01 2
Cardiovascular - Antihypertensives Bisoprolol C07AB07 2
Dermatological Fusidic acid D06AX01 2
Genito-urinary - Contraception Medroxyprogesterone G03AC06 2
Genito-urinary - Contraception Vaginal ring eluting etonogestrel and ethinyl estradiol G02BB01 2
Neurological - Antipsychotics Lithium N05AN01 2
Neurological - Other Methadone N07BC02 2
Neurological - Other Naltrexone N07BB04 2
Respiratory - Airway Beclomethasone R03BA01 2
Respiratory - Airway Salmeterol R03AC12 2
Respiratory - Other Budesonide R01AD05 2
Respiratory - Other Cetirizine R06AE07 2
Alimentary - Other Doxycycline A01AB22 1
Alimentary - Other Vitamin D A11CC01 1
Antiinfectives - Antibiotics Nitrofurantoin J01XE01 1
Antiinfectives - Antivirals Lamivudine J05AF05 1
Antiinfectives - HIV Abacavir J05AF06 1
Antiinfectives - HIV Efavirenz/ emtricitabine/ tenofovir J05AR06 1
Antiparasitic Hydroxychloroquine P01BA02 1
Cardiovascular - Antihypertensives Chlorthalidone C03BA04 1
Cardiovascular - Other Spironolactone C03DA01 1
Hormonal - Other Methimazole H03BB02 1
Immunomodulating - Other Azathioprine L04AX01 1
Musculo-skeletal - Other Allopurinol M04AA01 1
Neurological - Antidepressants Nortriptyline N06AA10 1
Neurological - Other Benztropine N04AC01 1
Respiratory - Airway Salmeterol/fluticasone R03AK06 1

All 2019 shortages by EML category

Category Shortages % of all shortages
Not an essential medicine 3072 75.70
Cardiovascular 267 6.58
Neurological 228 5.62
Alimentary 128 3.15
Antiinfectives 100 2.46
Genito-urinary 89 2.19
Dermatological 54 1.33
Blood 30 0.74
Musculo-skeletal 30 0.74
Respiratory 25 0.62
Hormonal 18 0.44
Sensory 15 0.37
Antiparasitic 1 0.02
Immunomodulating 1 0.02

Column

Shortages of Essential Medicines in 2019

106

Of all shortages in 2019

24.3%

About

Column

About this website

Hello. I am Jon Pipitone, medical student at Queen’s University, Kingston, Ontario, Canada.

This website is a work-in-progress and is a place to display my ongoing research into drug shortages in Canada. You can follow my progress on my blog https://jon.pipitone.ca/blog.

This work is done under supervision by Dr. Jacalyn Duffin, and is an extension of our earlier analysis:

Donelle, Jessy, Jacalyn Duffin, Jonathan Pipitone, and Brian White-Guay. “Assessing Canada’s Drug Shortage Problem.” CD Howe Institute Commentary 515, 2018. https://doi.org/10.2139/ssrn.3192558.

All of the code that powers this site, and other goodies can be found at https://github.com/pipitone/drug-shortages

Disclaimer: As this is ongoing research, the analysis and results presented here is likely to change, and has not undergone any peer review.

Questions or comments? Please send me an email at

Column

Data sources

drugshortagescanada.ca

Database of shortage and discontinuation reports. Active from March 2017 to present. Manufacturers are required to report.

Drug Product Database

Database of historical records of drug products in Canada. Maintained by Health Canada.

Terminology

DSC: Drug Shortages Canada database

DPD: Health Canada’s Drug Products Database

ATC: Anatomical Therapeutic Chemical Classification system

---
title: "Assessing Canada’s Drug Shortage Problem"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source_code: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse, warn.conflicts = FALSE)
library(lubridate)

# settings
FAR_FUTURE = parse_datetime("2100-12-31")
FAR_PAST = parse_datetime("1970-01-01")
DATA_UPDATED_DATE = parse_datetime("2019-12-25")

DPD_DATA_DIR = 'data/dpd/'  # Load the Health Canada Drug Product Database
DPD_DOWNLOAD = FALSE   # set to TRUE to attempt to download the latest DPD dataset
DPD_URL_BASE='http://www.hc-sc.gc.ca/dhp-mps/alt_formats/zip/prodpharma/databasdon/'

theme_set(theme_minimal())
caption = list(labs(caption =  paste(
  paste("source: drugshortagescanada.ca, last updated:", DATA_UPDATED_DATE), 
  "jon.pipitone.ca/research/drug-shortages", 
  sep="\n")))

# load data
DSCDATA= "data/dsc_shortages_2020-12-29.csv"
dsc_df = read_csv(DSCDATA, trim_ws = T, 
                  col_types = cols(
                    status = col_factor(),
                    shortage_reason_en = col_factor()
                  )) %>%
  select(-starts_with("fr_"), -ends_with("_fr")) %>%
  mutate(
    reason = fct_recode(shortage_reason_en,  
      "Demand increase" = "Demand increase for the drug.", 
      "Manufacturing distruption" = "Disruption of the manufacture of the drug.",
      "Ingredient shortage" = "Shortage of an active ingredient.", 
      "Ingredient shortage" = "Shortage of an inactive ingredient or component.",
      "Manufacturing practices" = "Requirements related to complying with good manufacturing practices.",
      "Other" = "Other (Please describe in comments)",
      "Shipping delay" = "Delay in shipping of the drug." 
    ) 
  ) %>%
  mutate(
    end_date_no_na = coalesce(actual_end_date, estimated_end_date, FAR_FUTURE), 
    start_date_no_na = coalesce(actual_start_date, anticipated_start_date, FAR_PAST))

## Parsual EML
# https://dx.doi.org/10.9778%2Fcmajo.20160122
emlist = read_csv('data/cleanmeds.csv', trim_ws=T, col_types = cols()) %>% 
  select(category, medication, ATC)

## DPD
if(DPD_DOWNLOAD) {
  for (f in c('allfiles.zip', 'allfiles_ia.zip', 'allfiles_ap.zip', 'allfiles_dr.zip')) {
    destfile = paste0(DPD_DATA_DIR, f)
    download.file(paste0(DPD_URL_BASE, f), destfile)
    unzip(destfile, exdir = DPD_DATA_DIR)
  }
}

tables = list(
  comp = c("DRUG_CODE","MFR_CODE","COMPANY_CODE","COMPANY_NAME","COMPANY_TYPE",
           "ADDRESS_MAILING_FLAG","ADDRESS_BILLING_FLAG",
           "ADDRESS_NOTIFICATION_FLAG","ADDRESS_OTHER","SUITE_NUMBER",
           "STREET_NAME","CITY_NAME","PROVINCE","COUNTRY","POSTAL_CODE",
           "POST_OFFICE_BOX","PROVINCE_F","COUNTRY_F"),
  form = c("DRUG_CODE","PHARM_FORM_CODE","PHARMACEUTICAL_FORM",
           "PHARMACEUTICAL_FORM_F"),
  ingred = c("DRUG_CODE","ACTIVE_INGREDIENT_CODE","INGREDIENT",
             "INGREDIENT_SUPPLIED_IND","STRENGTH","STRENGTH_UNIT",
             "STRENGTH_TYPE","DOSAGE_VALUE","BASE","DOSAGE_UNIT","NOTES",
             "INGREDIENT_F","STRENGTH_UNIT_F","STRENGTH_TYPE_F","DOSAGE_UNIT_F"),
  package = c("DRUG_CODE","UPC","PACKAGE_SIZE_UNIT","PACKAGE_TYPE",
              "PACKAGE_SIZE","PRODUCT_INFORMATION","PACKAGE_SIZE_UNIT_F",
              "PACKAGE_TYPE_F"),
  pharm = c("DRUG_CODE","PHARMACEUTICAL_STD"),
  drug = c("DRUG_CODE","PRODUCT_CATEGORIZATION","CLASS",
           "DRUG_IDENTIFICATION_NUMBER","BRAND_NAME","DESCRIPTOR",
           "PEDIATRIC_FLAG","ACCESSION_NUMBER","NUMBER_OF_AIS",
           "LAST_UPDATE_DATE","AI_GROUP_NO","CLASS_F","BRAND_NAME_F",
           "DESCRIPTOR_F"),
  route = c("DRUG_CODE","ROUTE_OF_ADMINISTRATION_CODE",
            "ROUTE_OF_ADMINISTRATION","ROUTE_OF_ADMINISTRATION_F"),
  sched = c("DRUG_CODE","SCHEDULE","SCHEDULE_F"),
  status = c("DRUG_CODE","CURRENT_STATUS_FLAG","STATUS","HISTORY_DATE",
             "STATUS_F","LOT_NUMBER","EXPIRATION_DATE"),
  ther = c("DRUG_CODE","TC_ATC_NUMBER","TC_ATC","TC_AHFS_NUMBER","TC_AHFS",
           "TC_ATC_F","TC_AHFS_F"),
  vet = c("DRUG_CODE","VET_SPECIES","VET_SUB_SPECIES","VET_SPECIES_F")
)

for (table_name in names(tables)) {
  headers = tables[[table_name]]
  # create new variables based on the DPD table names (e.g. dpd_vet) and load in the
  # data from the corresponding files (active, inactive, etc..) and merge them
  assign(paste0('dpd_', table_name), 
    dir(DPD_DATA_DIR, pattern = paste0(table_name, '.*.txt$'), full.names = TRUE) %>%
      keep(function(x) file.size(x) > 0) %>%
      map(read_csv, 
          col_names = headers, 
          locale = locale('en', date_format = '%d-%b-%Y'), 
          col_types = map(headers,  function (x) # guess base on name 
            case_when(
              endsWith(x, '_DATE') ~ 'D', 
              x == 'DRUG_CODE' ~ 'i', 
              TRUE ~ 'c')) %>% 
          setNames(headers), progress = FALSE) %>%
      reduce(rbind) %>%
      select(-ends_with("_F"))  # je ne parle pas bien le francais 
  )
}

## Add the DPD ATC number to the DSC data
din_to_atc = inner_join(dpd_drug, dpd_ther, by="DRUG_CODE") %>% 
  select(din = DRUG_IDENTIFICATION_NUMBER, dpd_atc_number = TC_ATC_NUMBER) %>% 
  distinct()

dsc_df = left_join(dsc_df, din_to_atc, by=c("din"))
```

Shortages
==========

Column
-----------------------------------------------------------------------

### Total number of drugs in shortage over time
```{r}
time.by.month = tibble(
  month = seq(parse_date("2017-01-01"), parse_date("2020-01-01"), by = "1 month"), 
  i = 1
)
# https://community.rstudio.com/t/tidy-way-to-range-join-tables-on-an-interval-of-dates/7881
shortages.by.month = 
  dsc_df %>%
  mutate(i = 1) %>%
  full_join(time.by.month, by = "i") %>%
  filter(int_overlaps(
    interval(month, month+months(1)-days(1)),
    interval(floor_date(actual_start_date, "month"), end_date_no_na))) %>%
  group_by(month) %>%
  summarize(n = n())

ggplot(shortages.by.month, aes(x = month, y = n)) + 
  geom_point() + geom_line() + 
  labs(x = "Date", y = "Number of drugs in shortage") + 
  caption
```

### Shortage start date

```{r, fig.asp=0.70}
dsc_df %>% 
  mutate(Month = floor_date(actual_start_date, "month")) %>% 
  filter(between(actual_start_date, parse_datetime("2017-01-01"), parse_datetime("2020-01-01")), 
         status != "avoided_shortage") %>%
  group_by(Month, status) %>% 
  summarize(count = n()) %>%
  ggplot(aes(x=Month, y = count, color = status)) + 
    geom_point() + geom_line() +  
    #geom_col(position="stack") + 
    scale_x_datetime(
      date_breaks = "1 year", 
      date_labels = "%Y") + 
    theme(legend.position="bottom") +
    labs(x = "Shortage start date", y = "Number of shortages", fill = "Current status") + 
    caption
```

Column 
-----------------------------------------------------------------------

### Duration of shortages
```{r}
data = dsc_df %>%
  filter(status %in% c("active_confirmed", "resolved")) %>%
  mutate(duration = interval(actual_start_date, actual_end_date)/weeks(1), 
         year = year(actual_start_date)) %>%
  filter(duration > 0, year >= 2017)

data %>%
  ggplot(aes(x = ceiling(duration))) + 
    geom_histogram(bins=50, position="identity") + 
    facet_grid(. ~ year) + 
    labs(fill = "Year", x = "Duration (weeks)", y = "# of shortages") + 
    theme(legend.position = "none") + 
    caption
```


### Causes of drug shortages

```{r, fig.asp=0.70}
dsc_df %>% 
  filter(status %in% c("resolved", "active_confirmed")) %>%
  mutate(reason=fct_infreq(reason)) %>%
  group_by(reason) %>%
  summarize(shortages=n()) %>%
  mutate(percent=shortages/sum(shortages)*100) %>% 
  ggplot(aes(x=2,y=percent,fill=reason)) + 
  xlim(0.5,2.5) + 
  geom_bar(width=1,stat="identity") + 
  coord_polar("y") + 
  geom_text(aes(label = paste0(round(percent), "%")), position = position_stack(vjust = 0.5), size=3) +
  labs(x=NULL,y=NULL,fill=NULL,
       title="Causes of drug shortages") + 
  theme_classic() + 
  theme(
    axis.line=element_blank(), 
    axis.text=element_blank(), 
    axis.ticks=element_blank()) +
  caption
```

Column {data-width=350}
-----------------------------------------------------------------------

### Active shortages
```{r}
active_shortages = dsc_df %>% 
  filter(
    status == "active_confirmed", 
    now() %within% interval(actual_start_date, end_date_no_na))
valueBox(nrow(active_shortages), icon="fa-capsules")
```

### Anticipated shortages next week
```{r}
week_start = floor_date(now(), "week")
this_week = interval(week_start, week_start + weeks(1))
next_week = int_shift(this_week, by = weeks(1))
expected_shortages = dsc_df %>% 
  filter(
    int_overlaps(next_week, interval(actual_start_date, end_date_no_na)))
valueBox(nrow(expected_shortages), icon="fa-clock")
```

### Summary (via the database)

```{r}
knitr::kable(dsc_df %>% group_by(status) %>% summarize(n = n()))
```


Essential Medicines 
=======================

Column 
-----------------

### Essential medicines impacted by shortages in 2019
```{r}
emls_with_shortages = dsc_df %>%
  filter(int_overlaps("2019-01-01" %--% "2019-12-31", actual_start_date %--% end_date_no_na)) %>%
  right_join(emlist, by=c("dpd_atc_number" = "ATC"))  %>%
  filter(!is.na(din))  %>%
  group_by(category, medication, dpd_atc_number) %>%
  summarize(Shortages = n()) %>%
  rename(Category = category, 
         Medication = medication,
         ATC = dpd_atc_number) %>%
  arrange(desc(Shortages))
knitr::kable(emls_with_shortages)
```

### All 2019 shortages by EML category
```{r}
shortages_by_eml = dsc_df %>%
  filter(int_overlaps("2019-01-01" %--% "2019-12-31", actual_start_date %--% end_date_no_na)) %>%
  left_join(emlist, by=c("dpd_atc_number" = "ATC")) %>%
  mutate(category = replace_na(category, "Not an essential medicine")) %>%
  mutate(category = str_replace(category, " -.*", "")) %>%
  group_by(category) %>%
  summarize(Shortages = n()) %>%
  mutate(percent_shortages = round(Shortages/sum(Shortages) * 100, digits=2)) %>%
  arrange(desc(percent_shortages)) %>%
  rename(Category = category, 
         "% of all shortages" = percent_shortages)
knitr::kable(shortages_by_eml)
```

Column {data-width=250}
-----------------------------------------------------------------------

### Shortages of Essential Medicines in 2019
```{r}
valueBox(nrow(emls_with_shortages), icon="fa-ambulance")
```

### Of all shortages in 2019
```{r}
valueBox(
  paste0(100-shortages_by_eml$'% of all shortages'[[1]], "%"),
  icon="fa-chart-pie")
```





About
=====

Column
------

### About this website

Hello. I am Jon Pipitone, medical student at Queen's University, Kingston, Ontario, Canada.

This website is a work-in-progress and is a place to display my ongoing research into drug shortages in Canada. You can follow my progress on my blog https://jon.pipitone.ca/blog. 

This work is done under supervision by [Dr. Jacalyn Duffin](https://jacalynduffin.ca/), and is an extension of our earlier analysis: 

*Donelle, Jessy, Jacalyn Duffin, Jonathan Pipitone, and Brian White-Guay. “Assessing Canada’s Drug Shortage Problem.” CD Howe Institute Commentary 515, 2018. https://doi.org/10.2139/ssrn.3192558.*

All of the code that powers this site, and other goodies can be found at https://github.com/pipitone/drug-shortages

*Disclaimer:* As this is ongoing research, the analysis and results presented here is likely to change, and has not undergone any peer review. 

Questions or comments? Please send me an email at jon@pipitone.ca

Column  {data-width=100}
----------------------------

### Data sources
##### [drugshortagescanada.ca](https://www.drugshortagescanada.ca)
Database of shortage and discontinuation reports.  Active from March 2017 to
present. Manufacturers are required to report.

##### [Drug Product Database](https://www.canada.ca/en/health-canada/services/drugs-health-products/drug-products/drug-product-database.html)
Database of historical records of drug products in Canada. Maintained by Health Canada.

##### [CLEANMeds Essential Medicines List](https://cleanmeds.ca)

### Terminology
**DSC**: Drug Shortages Canada database

**DPD**: Health Canada's Drug Products Database

**ATC**: Anatomical Therapeutic Chemical Classification system